home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2010 Summer - Disc 1 / WN_Ete2010_CD1.iso / Onglet5 / Weezo / Weezo setup.exe / {code_appDir} / www / local / uiResources.php < prev    next >
PHP Script  |  2010-05-19  |  7KB  |  190 lines

  1. <?php
  2. /**
  3.  * User Interface resources tab
  4.  *
  5.  * PHP version 5
  6.  *
  7.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  8.  * that is available through the world-wide-web at the following URI:
  9.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  10.  * the PHP License and are unable to obtain it through the web, please
  11.  * send a note to license@php.net so we can mail you a copy immediately.
  12.  *
  13.  * @category   NA
  14.  * @package    NA
  15.  * @author     Nicolas Bruley / Peer 2 World <contact@weezo.net>
  16.  * @copyright  2005-2009 Nicolas Bruley / Peer 2 World
  17.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  18.  * @version    CVS: $Id:$
  19.  * @link       http://www.weezo.net
  20.  * @since      File available since Release 2.0.0
  21.  */
  22.  
  23.  
  24. // Indicate an in-application display
  25. $_ENV['configurationEnvironment']='application';
  26.  
  27. require_once(INCLUDE_DIR.'outputFunctions.php');
  28.  
  29.  
  30. /**
  31.  ***************************************************************************************************************************
  32.  * Process Async command
  33.  ***************************************************************************************************************************
  34.  */
  35. if(cfIsAsync()){
  36.     cfAsyncHeader();
  37.     // Selected accordion update
  38.     if(isset($_POST['uiResouceAccordionUpdated'])){
  39.         cfGUpdateVar('uiResourceAccordion',$_POST['uiResouceAccordionUpdated']);
  40.     }
  41.     die(cfAsyncFooter());
  42. }
  43.  
  44. /**
  45.  * Detect Windows shell extension (context menu) request for share / send / publish
  46.  */
  47. if(file_exists($shellExt=cfAppTempDir().'/shellExtShared')){
  48.     $shellExtFiles=explode("\r\n",file_get_contents($shellExt));
  49.     $shellAction=array_shift($shellExtFiles);
  50.  
  51.     // Pre-process files array
  52.     $files=array(); foreach ($shellExtFiles as $utf8File) $files[]=utf8_decode(str_replace('\\','/',$utf8File));
  53.     if(count($files)>0) if($files[count($files)-1]=='') array_pop($files);
  54.  
  55.     // Select iframe
  56.     cfGUpdateVar('uiResourceAccordion',$shellAction);
  57.  
  58.     // Pass files list to relevant iframe
  59.     cfGSetVar('uiResourceShellAction',$files,true);
  60.  
  61.     // Remove file so it's not used another time
  62.     @unlink($shellExt);
  63. }
  64.  
  65. // UI request to select a given resource through GET parameter
  66. if(isset($_GET['resSelectedId'])) {
  67.     $rfn=cfArrayItem(cfMGetVar('weezoResourcesList'),$_GET['resSelectedId']);
  68.     if($rfn) {
  69.         cfGUpdateVar('uiResourceSelected',$rfn);
  70.         cfGUpdateVar('uiResourceAccordion','share');
  71.     }
  72. }
  73.  
  74.  
  75. /**
  76.  ***************************************************************************************************************************
  77.  * Insert page HEADER
  78.  ***************************************************************************************************************************
  79.  */
  80. cfInsertHEAD(false);
  81. ?>
  82. </head>
  83. <body style="padding:0;margin:0;overflow:hidden">
  84. <?php
  85. echo cfScriptLink('wz_dragdrop.js');
  86.  
  87. // Prepare accordion tabs
  88. $tabs=array();
  89. $tabs['share']=array('caption'=>strtoupper(cfCaption('doShare')),'src'=>'/local/uiResources/share.php','icon'=>outIcon('resources24'));
  90. $tabs['send']=array('caption'=>strtoupper(cfCaption('doSend')),'src'=>'/local/uiResources/send.php','icon'=>outIcon('directLink24'),'scroll'=>true);
  91. $tabs['publish']=array('caption'=>strtoupper(cfCaption('doPublish')),'src'=>'/local/uiResources/publish.php','icon'=>outIcon('icoXML24'),'scroll'=>true);
  92.  
  93. // Select publish panel
  94. if(cfGGetVar('uiResourcePublishPanel')) $tabs['publish']['src']='/local/uiResources/'.cfGGetVar('uiResourcePublishPanel').'.php';
  95.  
  96. // Select default tab
  97. $uiRA=cfGGetVar('uiResourceAccordion'); if(!$uiRA) $uiRA='share';
  98. switch ($uiRA){
  99.     case 'share':
  100.     case 'send':
  101.     case 'publish':
  102.         $tabs[$uiRA]['selected']=true;
  103.         break;
  104.     default:
  105.         $tabs['share']['selected']=true;
  106. }
  107.  
  108. //$tabs['send']['src']='/gfx/ok.png';
  109. outAccordion($tabs,800,453,array('callback'=>'uiResouceAccordionUpdated','hideFolded'=>1));
  110.  
  111. /**
  112.  * Script and inputs required to forward UI response to resource config iframe
  113.  */
  114. ?>
  115. <script type="text/javascript">
  116. var uiResourceAccordion="<?php echo $uiRA; ?>";
  117. function uiResouceAccordionUpdated(newTabName,prevTabName){
  118.     uiResourceAccordion=newTabName;
  119.     sendData('uiResouceAccordionUpdated='+newTabName);
  120.     if(frames[newTabName].tabSelected) frames[newTabName].tabSelected(1,newTabName);
  121.     if(frames[prevTabName].tabSelected) frames[prevTabName].tabSelected(0,prevTabName);
  122.     if(newTabName=='publish') {
  123.         var l=''+frames[newTabName].document.location;
  124.         var cmp='/local/uiResources/publish.php';
  125.         if(l.substr(l.length-cmp.length)!=cmp) frames[newTabName].document.location=cmp;
  126.     }
  127. }
  128. // Forward commands from UI to right iframe
  129. function forwardUICommand(){
  130.     var f=frames[uiResourceAccordion];// Forward to selected accordion's frame
  131.  
  132.     // web popup response to resource creation
  133.     if(dgi("UIReturnValue").value.substr(0,12)=='newResource:'){
  134.         dgi("UIReturnValue").value=dgi("UIReturnValue").value.substr(12);
  135.     }
  136.     // File drop/openfile(s) if selected accordion is share: forward to resource frame
  137.     else if(uiResourceAccordion=='share') f=frames['share'].frames['resourceConfigFrame'];
  138.  
  139.     // Get var name and value
  140.     var varName=dgi("UIReturnVarName").value, value=dgi("UIReturnValue").value;
  141.  
  142.     // webBrowser control display redraw bug workaround
  143.     if(varName=='UIRefreshCmd') return redrawDisplay();
  144.  
  145.     var n=f.dgi(varName);
  146.     if(!n) n=f.dgn(varName);
  147.     if(!n) return;
  148.     n.value=value;
  149.     if(n.onkeyup) n.onkeyup();
  150. }
  151.  
  152. // Sliding frames
  153. var slideFramePrev,slideFrameSteps=10;
  154. function slideFrame(frameName, URL, dir){
  155.     var prev,next;
  156.     if(!(prev=dgi(frameName).getElementsByTagName('IFRAME')[0])) return false;
  157.     prev.src=URL;
  158. }
  159. function slideFrameAnim(step,dir){
  160.     var t=slideFramePrev.offsetHeight*(((dir=='up')?-1:1)*(slideFrameSteps-step)/slideFrameSteps);
  161.     slideFramePrev.style.top=t
  162.  
  163.     if(dir=='up') dgi("slideFrame").style.top=t+slideFramePrev.offsetHeight;
  164.     else dgi("slideFrame").style.top=t-slideFramePrev.offsetHeight
  165.  
  166.     if(step>0) setTimeout('slideFrameAnim("'+(step-1)+'","'+dir+'")',1)
  167.     else{
  168.         removeNode(slideFramePrev);
  169.         slideFramePrev=null;
  170.         with(slideFramePrev=dgi("slideFrame")){
  171.             style.zIndex=style.position='';
  172.             style.top=style.left=0;
  173.             style.height='100%';
  174.             id='';
  175.         }
  176.     }
  177. }
  178. // webBrowser control display redraw bug workaround
  179. function redrawDisplay(){
  180.     dgi("redrawMask").style.display="";
  181.     setTimeout('dgi("redrawMask").style.display="none"',100);
  182. }
  183. </script>
  184. <input type="hidden" id="UIReturnVarName" name="UIReturnVarName">
  185. <input type="hidden" id="UIReturnValue" name="UIReturnValue" onkeyup="forwardUICommand()">
  186. <div id="redrawMask" style="position:absolute;top:0px;left:0px;width:100%;height:100%;background:white;display:none;filter:Alpha(opacity=1,style=0)">
  187. <?php
  188. echo cfDragRegisterItems('');
  189. ?>
  190. </body>